import request from '@/utils/request';

interface DocumentItem {
  fileId: string;
  fileName: string;
  fileType: string;
  fileUrl: string;
  updateTime: string;
  fileSize: string;
}

interface ListResponse {
  list: DocumentItem[];
  total: number;
}

export async function qryDocumentListPage(params: {
  pageIndex?: number;
  pageSize?: number;
  param?: {
    fileName?: string;
    [key: string]: any;
  };
}): Promise<ListResponse> {
  const response = await request('/document/qryDocumentListPage', {
    method: 'POST',
    data: params,
  });
  return {
    list: response.data || [],
    total: response.total || 0,
  };
}

export async function qryDocumentInfoDetail(params: {
  fileId: string;
}): Promise<DocumentItem> {
  const response = await request('/document/qryDocumentInfoDetail', {
    method: 'POST',
    data: params,
  });
  return response.data;
}

export async function addDocumentInfo(params: {
  fileName: string;
  fileUrl: string;
  fileType: string;
  fileSize: string;
}): Promise<void> {
  await request('/document/addDocumentInfo', {
    method: 'POST',
    data: params,
  });
}

export async function updateDocumentInfo(params: {
  fileId: string;
  fileName: string;
  fileUrl: string;
  fileType: string;
  fileSize: string;
}): Promise<void> {
  await request('/document/updateDocumentInfo', {
    method: 'POST',
    data: params,
  });
}

export async function deleteDocumentInfo(params: {
  fileId: string;
}): Promise<void> {
  await request('/document/deleteDocumentInfo', {
    method: 'POST',
    data: params,
  });
}